package c.h.a.k0.a;

import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
import android.hardware.SensorManager;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import c.h.a.m0.h;
import c.h.a.y.a;
import com.liuzh.deviceinfo.tests.TestesActivity;

/* compiled from: EarProximityTestFragment */
public class z extends a implements SensorEventListener {
    public SensorManager W;
    public Sensor X;
    public ImageView Y;
    public View Z;

    public void D(Context context) {
        super.D(context);
        ((TestesActivity) context).setTitle(2131689813);
    }

    public void E(Bundle bundle) {
        super.E(bundle);
        SensorManager sensorManager = (SensorManager) Z().getSystemService("sensor");
        this.W = sensorManager;
        if (sensorManager != null) {
            this.X = sensorManager.getDefaultSensor(8);
        }
    }

    public View G(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        if (this.Z == null) {
            View inflate = layoutInflater.inflate(2131493072, viewGroup, false);
            this.Z = inflate;
            ((TextView) inflate.findViewById(2131296715)).setText(2131689814);
            ImageView imageView = (ImageView) this.Z.findViewById(2131296633);
            this.Y = imageView;
            imageView.setImageResource(2131231117);
            if (s().getConfiguration().orientation == 2) {
                this.Y.setTranslationY((float) (-h.t(50.0f, s().getDisplayMetrics())));
            }
            this.Z.findViewById(2131296650).setOnClickListener(new e(this));
            this.Z.findViewById(2131296653).setOnClickListener(new f(this));
        }
        return this.Z;
    }

    public void N() {
        this.E = true;
        SensorManager sensorManager = this.W;
        if (sensorManager != null && this.X != null) {
            sensorManager.unregisterListener(this);
        }
    }

    public void P() {
        this.E = true;
        SensorManager sensorManager = this.W;
        if (sensorManager != null) {
            Sensor sensor = this.X;
            if (sensor != null) {
                sensorManager.registerListener(this, sensor, 3);
            }
        }
    }

    public void onAccuracyChanged(Sensor sensor, int i) {
    }

    public void onSensorChanged(SensorEvent sensorEvent) {
        if (sensorEvent.sensor.getType() == 8) {
            c.h.a.m0.p.a.b(new d(this, sensorEvent));
        }
    }
}
